home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 1 / PC World Interactive 1 - Nisan 1997.iso / nostalji / bbs / music / sbbook.arj / SBBOOK / SOURCE / TC / PLAYVOCD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  3.3 KB  |  120 lines

  1. /*********************************************************************
  2. *
  3. *  PROGRAM NAME: PLAYVOCD.C
  4. *
  5. *  COMPILER:     Borland/Turbo C/C++
  6. *
  7. *  DESCRIPTION:  Plays a .VOC file from the disk using the CTVDSK.DRV
  8. *                double buffering driver (accessed from SBSIM).  To run
  9. *                the program, type the following at the command line:
  10. *
  11. *                PLAYVOCD FILENAME
  12. *
  13. *                Where FILENAME is the drive/path/filename of the .VOC
  14. *                file to play.
  15. *
  16. *  NOTE: SBSIM driver must be loaded before running this program.
  17. *
  18. *********************************************************************/
  19. #define  VOC_DSK_DRIVER  0x02
  20.  
  21. #include <ctype.h>
  22. #include <conio.h>
  23. #include <fcntl.h>
  24. #include <io.h>
  25. #include <stdio.h>
  26. #include "drvrfunc.c"
  27. #include "drvrfunc.h"
  28.  
  29.  
  30. /********************************************************************/
  31. void main(int argc, char **argv)
  32. {
  33.   char Command,
  34.        UserQuit;
  35.  
  36.   int    FileHandle;
  37.   SIMERR RetValue;
  38.  
  39.   if (argc != 2)  // argc = no. of parameters entered on command line
  40.   {
  41.     puts("Command line must contain EXACTLY ONE filename parameter!");
  42.     return;  // Terminate program
  43.   }
  44.  
  45.  
  46.   /*--- SEE IF SBSIM DRIVER HAS LOADED ------------*/
  47.   SIMint = FindDvr("SBSIM", 0x0103);  // Get SBSIM's interrupt no.
  48.   if (SIMint == 0)
  49.   {
  50.     puts("SBSIM driver not loaded!");
  51.     return;  // Terminate program
  52.   }
  53.  
  54.   /*--- SEE IF CTVDSK.DRV DRIVER HAS LOADED -------*/
  55.   if (!(GetDrvrs() & VOC_DSK_DRIVER))
  56.   {
  57.     puts("CTVDSK.DRV not loaded!");
  58.     return;  // Terminate program
  59.   }
  60.  
  61.  
  62.   /*--- LOAD THE FILE SPECIFIED ON COMMAND LINE (stored in argv[1]) ----*/
  63.   if ((FileHandle = _open(argv[1], O_BINARY | O_RDONLY)) == -1)
  64.   {
  65.     printf("FILE: %s not successfully opened!\n", argv[1]);
  66.     return;  // Terminate program
  67.   }
  68.  
  69.  
  70.   /*--- StartSnd() LOADS THE FILE AND INITIALIZES THE CTVDSK.DRV DRIVER. ---*/
  71.   RetValue = StartSnd(DskVoice, (void far *) argv[1], NULL, NULL);
  72.   if (RetValue != SIMerr_NoErr)
  73.   {
  74.     printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
  75.     _close(FileHandle);
  76.     return;  // Terminate program
  77.   }
  78.  
  79.   /*--- BEGIN PLAYING OF THE FILE -----------------------------------------*/
  80.   RetValue = PlaySnd(DskVoice);
  81.   if (RetValue != SIMerr_NoErr)
  82.   {
  83.     printf("ERROR CALLING SBSIM: %s\n", errorMsg[RetValue]);
  84.     _close(FileHandle);
  85.     return;  // Terminate program
  86.   }
  87.  
  88.   clrscr();  // Clear screen
  89.   printf("\n\n\n\n\n     SELECT ONE OF THE FOLLOWING OR WAIT UNTIL DONE:\n\n");
  90.   printf("                   (P)ause\n");
  91.   printf("                   (R)esume\n");
  92.   printf("                   (Q)uit\n");
  93.  
  94.   UserQuit = FALSE;
  95.  
  96.  
  97.   /*--- PROCESS USER INTERACTION OR WAIT FOR SOUND TO STOP -----------*/
  98.   do
  99.   {
  100.     if (kbhit())  // Was a key pressed?
  101.     {
  102.       Command = toupper(getch());  // Get char typed and convert to upper case
  103.       if (Command == 'P')
  104.     PauseSnd(DskVoice);
  105.       else if (Command == 'R')
  106.     ResumeSnd(DskVoice);
  107.       else if (Command == 'Q')
  108.     UserQuit = TRUE;
  109.     }
  110.     // Exit do-while loop if file is done playing or user typed 'Q'
  111.   } while (GetSndStat(DskVoice) != 0 && UserQuit == FALSE);
  112.  
  113.  
  114.   /*--- IF SOUND IS STILL PLAYING AND USER HIT 'Q', STOP THE SOUND ---*/
  115.   if (GetSndStat(DskVoice) != 0 && UserQuit == TRUE)
  116.     StopSnd(DskVoice);
  117.  
  118.   return;
  119. }
  120.